#include "SGUI_Port.h"
//#include "spi.h"
#include "stdlib.h"
#include "string.h"
#include "SGUI_FontResource.h"
#include "SGUI_IconResource.h"
#include "LCD_def.h"

unsigned char BMP1_[] = {
	0x00,0x03,0x05,0x09,0x11,0xFF,0x11,0x89,0x05,0xC3,0x00,0xE0,0x00,0xF0,0x00,0xF8,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x28,0xFF,0x11,0xAA,0x44,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x83,0x01,0x38,0x44,0x82,0x92,
	0x92,0x74,0x01,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x44,0xFF,0x01,0x7D,
	0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x7D,0x01,0xFF,0x00,
	0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,
	0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,
	0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x3F,0x03,0x03,
	0xF3,0x13,0x11,0x11,0x11,0x11,0x11,0x11,0x01,0xF1,0x11,0x61,0x81,0x01,0x01,0x01,
	0x81,0x61,0x11,0xF1,0x01,0x01,0x01,0x01,0x41,0x41,0xF1,0x01,0x01,0x01,0x01,0x01,
	0xC1,0x21,0x11,0x11,0x11,0x11,0x21,0xC1,0x01,0x01,0x01,0x01,0x41,0x41,0xF1,0x01,
	0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x11,0x11,0x11,0x11,0x11,0xD3,0x33,
	0x03,0x03,0x3F,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xE0,0x00,0x00,
	0x7F,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x7F,0x00,0x00,0x01,0x06,0x18,0x06,
	0x01,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x40,0x40,0x7F,0x40,0x40,0x00,0x00,0x00,
	0x1F,0x20,0x40,0x40,0x40,0x40,0x20,0x1F,0x00,0x00,0x00,0x00,0x40,0x40,0x7F,0x40,
	0x40,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x40,0x30,0x0C,0x03,0x00,0x00,
	0x00,0x00,0xE0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x06,0x06,
	0x06,0x06,0x04,0x04,0x04,0x84,0x44,0x44,0x44,0x84,0x04,0x04,0x84,0x44,0x44,0x44,
	0x84,0x04,0x04,0x04,0x84,0xC4,0x04,0x04,0x04,0x04,0x84,0x44,0x44,0x44,0x84,0x04,
	0x04,0x04,0x04,0x04,0x84,0x44,0x44,0x44,0x84,0x04,0x04,0x04,0x04,0x04,0x84,0x44,
	0x44,0x44,0x84,0x04,0x04,0x84,0x44,0x44,0x44,0x84,0x04,0x04,0x04,0x04,0x06,0x06,
	0x06,0x06,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x10,0x18,0x14,0x12,0x11,0x00,0x00,0x0F,0x10,0x10,0x10,
	0x0F,0x00,0x00,0x00,0x10,0x1F,0x10,0x00,0x00,0x00,0x08,0x10,0x12,0x12,0x0D,0x00,
	0x00,0x18,0x00,0x00,0x0D,0x12,0x12,0x12,0x0D,0x00,0x00,0x18,0x00,0x00,0x10,0x18,
	0x14,0x12,0x11,0x00,0x00,0x10,0x18,0x14,0x12,0x11,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,
	0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x7F,0x03,0x0C,0x30,0x0C,0x03,0x7F,0x00,0x00,0x38,0x54,0x54,0x58,0x00,0x00,
	0x7C,0x04,0x04,0x78,0x00,0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xAA,0xAA,0xAA,
	0x28,0x08,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x03,0x0C,0x30,0x0C,0x03,0x7F,
	0x00,0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00,0x7F,0x02,0x04,0x08,0x10,0x7F,0x00,
};

#define PAGE_SIZE    8
#define XLevelL		0x00
#define XLevelH		0x10
#define YLevel       0xB0
#define	Brightness	 0xFF
#define WIDTH 	     LCD_Point_W
#define HEIGHT 	 LCD_Point_H
#define Buffer_size  LCD_Point_W*LCD_Point_H/8

#define OLED_CMD     0
#define OLED_DATA    1




int OLED_Init()
{

	return 0;
}


static unsigned char OLED_Buffer[Buffer_size] =
{
	0x00
};

static unsigned char OLED_OperateBuffer[Buffer_size/2] =
{
	0x00
};

void OLED_WR_Byte(unsigned dat,unsigned cmd)
{
	if(cmd)
	{
	}
	else
	{

	}

}

void OLED_Set_Pixel(int x, int y,unsigned int color)
{
	if(color)
	{
		OLED_Buffer[(y/PAGE_SIZE)*WIDTH+x]|= (1<<(y%PAGE_SIZE))&0xff;
	}
	else
	{
		OLED_Buffer[(y/PAGE_SIZE)*WIDTH+x]&= ~((1<<(y%PAGE_SIZE))&0xff);
	}
}

int OLED_Get_Pixel(int x, int y)
{
	int Pixel;
	Pixel = OLED_Buffer[(y/PAGE_SIZE)*WIDTH+x]&(1<<(y%PAGE_SIZE))&0xff;
	return Pixel;
}

void OLED_Display(void)
{
	uint16_t x,y;
	for(x=0;x<WIDTH;x++)
	{
		for(y = 0;y<HEIGHT;y++ )
        {
            if(OLED_Get_Pixel(x,y))
            {
                lcd_points[x][y] = 1;
            }
            else
            {
                lcd_points[x][y] = 0;
            }
        }
	}
    lcd_Screen_Refresh();
}

void OLED_Clear( void )
{
	memset(OLED_Buffer,0,sizeof(OLED_Buffer));
}


void GUI_Fill(int sx,int sy,int Width,int Height,unsigned int color)
{
	uint16_t i,j;
	for(i=0;i<Height;i++)
	{
		for(j=0;j<Width;j++)
		{
				OLED_Set_Pixel(sx+j, sy+i,color);
		}
	}
}

SGUI_SCR_DEV Scream_Operate;

void SGUI_Init()
{
	Scream_Operate.stSize.iWidth = WIDTH;
	Scream_Operate.stSize.iHeight = HEIGHT;

	Scream_Operate.stBuffer.pBuffer = OLED_OperateBuffer;
	Scream_Operate.stBuffer.sSize = Buffer_size/2;

	Scream_Operate.fnInitialize = OLED_Init;
	Scream_Operate.fnClear = OLED_Clear;
	Scream_Operate.fnSetPixel = OLED_Set_Pixel;
	Scream_Operate.fnGetPixel = OLED_Get_Pixel;
	Scream_Operate.fnFillRect = GUI_Fill;
	Scream_Operate.fnSyncBuffer = OLED_Display;
}

void SGUI_Test()
{

	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_Basic_DrawLine(&Scream_Operate,0,0,127,63,SGUI_COLOR_FRGCLR);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(500);

	SGUI_Basic_ClearScreen(&Scream_Operate);
	for(int i = 0;i<8;i++)
		SGUI_Basic_DrawHorizontalLine(&Scream_Operate,0,127,i*7,SGUI_COLOR_FRGCLR);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(500);

	SGUI_Basic_ClearScreen(&Scream_Operate);
	for(int i = 0;i<8;i++)
        SGUI_Basic_DrawVerticalLine(&Scream_Operate,i*10,0,63,SGUI_COLOR_FRGCLR);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(500);

	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_Basic_DrawRectangle(&Scream_Operate,10,10,40,40,SGUI_COLOR_FRGCLR,SGUI_COLOR_FRGCLR);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(500);
	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_Basic_DrawRectangle(&Scream_Operate,10,10,40,40,SGUI_COLOR_FRGCLR,SGUI_COLOR_BKGCLR);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(500);

	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_Basic_DrawRoundedRectangle(&Scream_Operate,10,10,40,40,10,SGUI_COLOR_FRGCLR,SGUI_COLOR_BKGCLR);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(500);
	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_Basic_DrawRoundedRectangle(&Scream_Operate,10,10,40,40,10,SGUI_COLOR_BKGCLR,SGUI_COLOR_FRGCLR);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(500);

    SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_Basic_DrawCircle(&Scream_Operate,63,31,3,SGUI_COLOR_FRGCLR,SGUI_COLOR_TRANS);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(200);
	SGUI_Basic_DrawCircle(&Scream_Operate,63,31,6,SGUI_COLOR_FRGCLR,SGUI_COLOR_TRANS);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(200);
	SGUI_Basic_DrawCircle(&Scream_Operate,63,31,9,SGUI_COLOR_FRGCLR,SGUI_COLOR_TRANS);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(200);
	SGUI_Basic_DrawCircle(&Scream_Operate,63,31,12,SGUI_COLOR_FRGCLR,SGUI_COLOR_TRANS);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(200);
	SGUI_Basic_DrawCircle(&Scream_Operate,63,31,15,SGUI_COLOR_FRGCLR,SGUI_COLOR_TRANS);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(500);

	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_Basic_DrawRoundedRectangle(&Scream_Operate,10,10,40,40,10,SGUI_COLOR_BKGCLR,SGUI_COLOR_FRGCLR);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(1500);

	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_Basic_FillRectangleArea(&Scream_Operate,10,10,100,40,SGUI_COLOR_FRGCLR);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(1000);

	SGUI_RECT BMP1_RECT = {0,0,127,63};
	SGUI_POINT BMP1_POINT = {0,0};
	SGUI_BMP_RES BMP1_RES = {128,64,BMP1_};
	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_Basic_DrawBitMap(&Scream_Operate,&BMP1_RECT,&BMP1_POINT,&BMP1_RES,SGUI_DRAW_NORMAL);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(2000);


	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_Basic_DrawBitMap(&Scream_Operate,&BMP1_RECT,&BMP1_POINT,&SGUI_RES_ICON_ERROR_16,SGUI_DRAW_NORMAL);
	BMP1_POINT.iX = 20;
	SGUI_Basic_DrawBitMap(&Scream_Operate,&BMP1_RECT,&BMP1_POINT,&SGUI_RES_ICON_INFORMATION_16,SGUI_DRAW_NORMAL);
	BMP1_POINT.iX = 40;
	SGUI_Basic_DrawBitMap(&Scream_Operate,&BMP1_RECT,&BMP1_POINT,&SGUI_RES_ICON_QUESTION_16,SGUI_DRAW_NORMAL);
	BMP1_POINT.iX = 60;
	BMP1_POINT.iY = 0;
	SGUI_Basic_DrawBitMap(&Scream_Operate,&BMP1_RECT,&BMP1_POINT,&SGUI_RES_ICON_WARNING_16,SGUI_DRAW_NORMAL);
	BMP1_POINT.iX = 80;
	BMP1_POINT.iY = 0;
	SGUI_Basic_DrawBitMap(&Scream_Operate,&BMP1_RECT,&BMP1_POINT,&SGUI_RES_ICON_ERROR_24,SGUI_DRAW_NORMAL);
	BMP1_POINT.iX = 100;
	BMP1_POINT.iY = 0;
	SGUI_Basic_DrawBitMap(&Scream_Operate,&BMP1_RECT,&BMP1_POINT,&SGUI_RES_ICON_INFORMATION_24,SGUI_DRAW_NORMAL);
	BMP1_POINT.iX = 0;
	BMP1_POINT.iY = 30;
	SGUI_Basic_DrawBitMap(&Scream_Operate,&BMP1_RECT,&BMP1_POINT,&SGUI_RES_ICON_QUESTION_24,SGUI_DRAW_NORMAL);
	BMP1_POINT.iX = 60;
	BMP1_POINT.iY = 30;
	SGUI_Basic_DrawBitMap(&Scream_Operate,&BMP1_RECT,&BMP1_POINT,&SGUI_RES_ICON_WARNING_24,SGUI_DRAW_NORMAL);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(5000);



	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_RECT TXT1_RECT = {20,30,100,16};
	SGUI_POINT TXT1_POINT = {0,0};
	SGUI_Text_DrawText(&Scream_Operate, "GUI,Hello,SGUI!",&SGUI_DEFAULT_FONT_16, &TXT1_RECT , &TXT1_POINT, SGUI_DRAW_REVERSE);
	Scream_Operate.fnSyncBuffer();
    int TXT1_Cnt = 0;
	while(TXT1_Cnt < 20)
	{
		TXT1_POINT.iX = (TXT1_Cnt)*5;
		SGUI_Text_DrawText(&Scream_Operate, "Hello,SGUI!",&SGUI_DEFAULT_FONT_12, &TXT1_RECT , &TXT1_POINT, SGUI_DRAW_NORMAL);
		Scream_Operate.fnSyncBuffer();
		TXT1_Cnt++;
		HAL_Delay(100);
	}
	HAL_Delay(500);

	SGUI_Basic_ClearScreen(&Scream_Operate);
	TXT1_POINT.iX = 40;
	TXT1_POINT.iY = 0;
	TXT1_RECT.iX = 51;
	TXT1_RECT.iY = 1;
	TXT1_RECT.iWidth = 38;
	TXT1_RECT.iHeight = 28;
	SGUI_Text_DrawMultipleLinesText(&Scream_Operate, "Hello,SGUI!",&SGUI_DEFAULT_FONT_12, &TXT1_RECT , 10, SGUI_DRAW_NORMAL);
	SGUI_Basic_DrawRectangle(&Scream_Operate,50,0,40,30,SGUI_COLOR_FRGCLR,SGUI_COLOR_TRANS);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(1000);

	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_AREA_SIZE stTextSize;
	SGUI_Text_GetTextExtent("Fixed size test.",&SGUI_DEFAULT_FONT_16,&stTextSize);
	TXT1_RECT.iX = 51;
	TXT1_RECT.iY = 1;
	TXT1_RECT.iWidth = stTextSize.iWidth;
	TXT1_RECT.iHeight = stTextSize.iHeight;
	TXT1_POINT.iX = 0;
	TXT1_POINT.iY = 0;
	SGUI_Text_DrawText(&Scream_Operate, "Fixed size test.",&SGUI_DEFAULT_FONT_12, &TXT1_RECT , &TXT1_POINT, SGUI_DRAW_NORMAL);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(1000);

	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_PROCBAR_STRUCT stPROCBAR_bar;

	stPROCBAR_bar.Data.Value = 0;
	stPROCBAR_bar.Parameter.PosX = 10;
	stPROCBAR_bar.Parameter.PosY = 10;
	stPROCBAR_bar.Parameter.Width = 7;
	stPROCBAR_bar.Parameter.Height = 44;
	stPROCBAR_bar.Parameter.Direction = SGUI_PROCBAR_UP;
	stPROCBAR_bar.Parameter.MaxValue = 100;
	int PROCBAR_bar_Cnt = 0;
	while(PROCBAR_bar_Cnt <= 100)
	{
		stPROCBAR_bar.Data.Value = PROCBAR_bar_Cnt;
		SGUI_ProcessBar_Repaint(&Scream_Operate,&stPROCBAR_bar);
		Scream_Operate.fnSyncBuffer();
		PROCBAR_bar_Cnt++;
        HAL_Delay(20);
	}
	HAL_Delay(500);


	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_SCROLLBAR_STRUCT stScrollBar;
	stScrollBar.stData.sValue = 0;
	stScrollBar.stParam.stLayout.iX = 20;
	stScrollBar.stParam.stLayout.iY = 20;
	stScrollBar.stParam.stLayout.iWidth = 106;
	stScrollBar.stParam.stLayout.iHeight = 15;
	stScrollBar.stParam.sMaxValue = 20;
	stScrollBar.stParam.eDirection = SGUI_SCROLLBAR_HORIZONTAL;
	SGUI_ScrollBar_Initialize(&stScrollBar, &stScrollBar.stParam);
    int ScrollBar_Cnt = 0;
	while(ScrollBar_Cnt <= 20)
	{

		stScrollBar.stData.sValue =ScrollBar_Cnt ;
		SGUI_ScrollBar_SetValue(&stScrollBar,stScrollBar.stData.sValue);
	    SGUI_ScrollBar_Repaint(&Scream_Operate,&stScrollBar);
		Scream_Operate.fnSyncBuffer();
		ScrollBar_Cnt++;
		HAL_Delay(100);
	}
	HAL_Delay(500);

	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_NOTICT_BOX Notice_Box;
	Notice_Box.cszNoticeText = "Error,tis is do not need!";
	Notice_Box.pstIcon = &SGUI_RES_ICON_ERROR_16;
    SGUI_Notice_FitArea(&Scream_Operate,&Notice_Box.stLayout);
	static int i = 0;
	SGUI_Notice_Repaint(&Scream_Operate, &Notice_Box,  &SGUI_DEFAULT_FONT_8,i);
	Scream_Operate.fnSyncBuffer();
	HAL_Delay(1000);


	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_RTGRAPH_CONTROL RealtimeGraphControl = {50, -50, SGUI_TRUE, 6, 0};
	SGUI_RTGRAPH_DATA RealtimeGraphData = {{0},{0},{0},0,0};//ע��ռ�ռ��
	SGUI_RTGRAPH RealtimeGraph = {{1, 9, 126, 49},&RealtimeGraphData,&RealtimeGraphControl};

	RealtimeGraph.stLayout.iX = 1;
	RealtimeGraph.stLayout.iY = 1;
	RealtimeGraph.stLayout.iWidth = 127;
	RealtimeGraph.stLayout.iHeight = 60;
	RealtimeGraphControl.yAxisMax = 30;
	RealtimeGraphControl.yAxisMin = -30;
	RealtimeGraphControl.EnableBaseline = true;
	RealtimeGraphControl.xAxisStepPixel = 1;
	RealtimeGraph.Control = &RealtimeGraphControl;
	RealtimeGraph.Data = &RealtimeGraphData;

	SGUI_RealtimeGraph_Initialize(&RealtimeGraph);
	SGUI_Basic_DrawRectangle(&Scream_Operate, 0, 0, SGUI_RECT_WIDTH(Scream_Operate.stSize), SGUI_RECT_HEIGHT(Scream_Operate.stSize), SGUI_COLOR_FRGCLR, SGUI_COLOR_BKGCLR);
	SGUI_RealtimeGraph_Repaint(&Scream_Operate, &RealtimeGraph);
	Scream_Operate.fnSyncBuffer();
	int text_time = 0;
	 i = 0;
	while(true)
	{
		if(text_time < 2)
		{
			i++;
			if(i >= 20)
			{
				i = -20;
				text_time++;
			}
			SGUI_RealtimeGraph_AppendValue(&Scream_Operate, &RealtimeGraph, i);
			SGUI_RealtimeGraph_Repaint(&Scream_Operate, &RealtimeGraph);
			Scream_Operate.fnSyncBuffer();
			HAL_Delay(40);
		}
		else
        {
            break;
        }

	}

	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_ITEMS_ITEM arrstItemsGroup1[] =
	{
		{"Items1",NULL,NULL,NULL},
		{"Items2",NULL,NULL,NULL},
		{"Items3",NULL,NULL,NULL},
		{"Items4",NULL,NULL,NULL},
		{"Items5",NULL,NULL,NULL},
		{"Items6",NULL,NULL,NULL},
		{"Items7",NULL,NULL,NULL},
		{"Items8",NULL,NULL,NULL},
	};
	SGUI_ITEMS_BASE stItems1 =
	{
		{0,0,0,0},
		arrstItemsGroup1,
		&arrstItemsGroup1[3],
		sizeof(arrstItemsGroup1)/sizeof(SGUI_ITEMS_ITEM),
	};
	TXT1_RECT.iX = 10;
	TXT1_RECT.iY = 1;
	TXT1_RECT.iWidth = 60;
	TXT1_RECT.iHeight = 62;
	SGUI_Basic_DrawRectangle(&Scream_Operate,9,0,65,64,SGUI_COLOR_FRGCLR,SGUI_COLOR_BKGCLR);
	SGUI_ItemsBase_Initialize(&stItems1, &TXT1_RECT, &SGUI_DEFAULT_FONT_12, arrstItemsGroup1, sizeof(arrstItemsGroup1)/sizeof(SGUI_ITEMS_ITEM));
	 text_time = 0;
	while(text_time < 9)
	{

		stItems1.stSelection.iIndex = text_time++;
		SGUI_ItemsBase_JumpItem(stItems1.stSelection.pstItem,-stItems1.stSelection.iIndex );
		stItems1.stSelection.pstItem = &arrstItemsGroup1[stItems1.stSelection.iIndex];
		SGUI_ItemsBase_Repaint(&Scream_Operate,&stItems1);
		Scream_Operate.fnSyncBuffer();
		HAL_Delay(500);
	}
	HAL_Delay(2000);

	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_LIST List;
	SGUI_ITEMS_ITEM arrstListGroup1[] =
	{
		{"List1",NULL,NULL,NULL},
		{"List2",NULL,NULL,NULL},
		{"List3",NULL,NULL,NULL},
		{"List4",NULL,NULL,NULL},
		{"List5",NULL,NULL,NULL},
		{"List6",NULL,NULL,NULL},
		{"List7",NULL,NULL,NULL},
		{"List8",NULL,NULL,NULL},
	};
	TXT1_RECT.iX = 10;
	TXT1_RECT.iY = 1;
	TXT1_RECT.iWidth = 60;
	TXT1_RECT.iHeight = 62;
	SGUI_CSZSTR List_Title = "List test";
	SGUI_List_Initialize(&List, &TXT1_RECT, &SGUI_DEFAULT_FONT_12,List_Title, arrstListGroup1, sizeof(arrstListGroup1)/sizeof(SGUI_ITEMS_ITEM));
	 text_time = 0;
	while(text_time < 8)
	{

		List.stItems.stSelection.iIndex = text_time++;
		List.stItems.stSelection.pstItem = &arrstListGroup1[List.stItems.stSelection.iIndex];
		SGUI_List_Repaint(&Scream_Operate, &List);
		Scream_Operate.fnSyncBuffer();
		HAL_Delay(600);
	}
	HAL_Delay(2000);

	SGUI_MENU Menu;
	Menu.stLayout.iX = 2;
	Menu.stLayout.iY = 2;
	Menu.stLayout.iWidth = 120;
	Menu.stLayout.iHeight = 60;

	TXT1_RECT.iX = 1;
	TXT1_RECT.iY = 2;
	TXT1_RECT.iWidth = 40;
	TXT1_RECT.iHeight = 60;

	SGUI_ITEMS_ITEM arrstMenuGroup1[] =
	{
		{"Menu1",NULL,NULL,NULL},
		{"Menu2",NULL,NULL,NULL},
		{"Menu3",NULL,NULL,NULL},
		{"Menu4",NULL,NULL,NULL},
		{"Menu5",NULL,NULL,NULL},
		{"Menu6",NULL,NULL,NULL},
		{"Menu7",NULL,NULL,NULL},
		{"Menu8",NULL,NULL,NULL},
	};
	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_Menu_Initialize(&Menu, &Menu.stLayout, &SGUI_DEFAULT_FONT_12, arrstMenuGroup1, sizeof(arrstMenuGroup1)/sizeof(SGUI_ITEMS_ITEM));
	SGUI_Menu_Resize(&Menu, &TXT1_RECT);//�����趨Menu��ʾ����
	SGUI_Menu_PopupSubMenu(&Scream_Operate, &Menu, &TXT1_RECT);

	text_time = 0;
	while( text_time < 8)
	{
		Menu.stItems.stSelection.iIndex = text_time++;
		Menu.stItems.stSelection.pstItem = &arrstMenuGroup1[Menu.stItems.stSelection.iIndex];
		SGUI_Menu_Repaint(&Scream_Operate, &Menu);
		Scream_Operate.fnSyncBuffer();
		HAL_Delay(600);
	}
	HAL_Delay(2000);

	SGUI_NUM_VARBOX_STRUCT stVariableBox;
	SGUI_NUM_VARBOX_PARAM VariableBoxPara = {{1,1,50,20},0,20};
	VariableBoxPara.pstFontRes = &SGUI_DEFAULT_FONT_12;
	VariableBoxPara.eAlignment = SGUI_CENTER;
	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_NumberVariableBox_Initialize(&stVariableBox, &VariableBoxPara);//��ʼ��NUM Param
	text_time = 0;
	while( text_time < 10)
	{
		stVariableBox.stData.iValue = text_time++;
		SGUI_NumberVariableBox_Repaint(&Scream_Operate, &stVariableBox, SGUI_DRAW_REVERSE);//����
		Scream_Operate.fnSyncBuffer();
		HAL_Delay(200);
	}
	//VariableBox text
	SGUI_TEXT_VARBOX_STRUCT stVarBox;
	SGUI_TEXT_VARBOX_PARAM stVatBoxPara = {{1,25,100,20},&SGUI_DEFAULT_FONT_12,16};
	SGUI_Basic_ClearScreen(&Scream_Operate);
	SGUI_SZSTR szVarBoxBuff = "0123456789ABCDEF";
	SGUI_TextVariableBox_Initialize(&stVarBox, &stVatBoxPara, szVarBoxBuff);
 	text_time = 0;
	while(text_time < 16)
	{
		stVarBox.stData.iFocusIndex = text_time++ ;
		SGUI_TextVariableBox_Repaint(&Scream_Operate, &stVarBox ,'\0', SGUI_DRAW_NORMAL);
		Scream_Operate.fnSyncBuffer();
		HAL_Delay(100);
	}
	HAL_Delay(2000);


}
